//
//  Engineer_listVC.swift
//  EngineerModel
//
//  Created by SSLong on 2018/4/18.
//  Copyright © 2018年 孙世龙. All rights reserved.
//

import UIKit


//MARK:尺寸
let ScreenHeight  : CGFloat = UIScreen.main.bounds.size.height      //屏幕高度
let ScreenWidth   : CGFloat = UIScreen.main.bounds.size.width       //屏幕宽度

class Engineer_listVC: UIViewController {
    var dataArray = Array<Any>()        //数组

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "校准号列表"
        self.view.addSubview(dataTableView)
    }
    lazy var dataTableView:UITableView = {
        var tableview = UITableView.init(frame: CGRect.init(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight), style: .plain)
        tableview.delegate = self
        tableview.dataSource = self
        tableview.tableFooterView = UIView.init(frame: CGRect.zero)
        tableview.register(UINib.init(nibName: "Engineer_Cell", bundle: nil), forCellReuseIdentifier: "Engineer_Cell")
        
        return tableview
    }()

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */
}
extension Engineer_listVC: UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60.0
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cellid = "Engineer_Cell"
        
//        let exhibit = resultArray[indexPath.row]
        
        //2、自定义cell
        var cell:Engineer_Cell? = tableView.dequeueReusableCell(withIdentifier: cellid) as? Engineer_Cell
        if cell == nil {
            cell = Engineer_Cell.init(style: .default, reuseIdentifier: cellid)
        }
        cell?.iBeaconIDLabel.text = String.init(format: "major:%@--minor:%@", "1","2")
        cell?.rssiLabel.text = "6.00"
        cell?.accessoryType = UITableViewCellAccessoryType.checkmark
        
        return cell!
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        print("点击",indexPath.row)
        
        // MARK: - 1、传入设置卡号，来源是数据库
        let ibe = HD_Beacon_Obj.init()
        ibe.major = 108
        ibe.minor = 108
        ibe.accIos = 8.0
        
        
        let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
        let vc: Engineer_adjustVC = storyboard.instantiateViewController(withIdentifier: "Engineer_adjustVC") as! Engineer_adjustVC
        vc.adjustModel = ibe
        
        self.navigationController?.pushViewController(vc, animated: true)
    }
}
